public class t1475 {
    //1475. 商品折扣后的最终价格 简单
    public static void main(String[] args) {
        int prices[] = {10, 1, 1, 6};
        for (int i : finalPrices(prices)) {
            System.out.print(i + " ");
        }
    }

    public static int[] finalPrices(int[] prices) {
        int arr[] = new int[prices.length];
        for (int i = 0; i < prices.length; i++) {
            boolean flag = false;
            for (int j = i + 1; j < prices.length; j++) {
                if (prices[i] >= prices[j]) {
                    flag = true;
                    arr[i] = prices[i] - prices[j];
                    break;
                }
            }
            if (arr[i] == 0 && !flag) {
                arr[i] = prices[i];
            }
        }
        return arr;
    }
}
